package com.liushao.listener;

import com.liushao.SmsDTO;
import com.liushao.constant.MQConst;
import com.liushao.service.MsmService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: untitled1
 * @ClassName SmsReceiver
 * @description: 监听类
 * @author: 陈修华
 * @create: 2025−01-22 10:27
 * @Version 1.0
 **/
@Component
public class SmsReceiver {

    @Autowired
    private MsmService msmService;

  @RabbitListener(
          bindings = @QueueBinding(
                  value = @Queue(value = MQConst.QUEUE_SMS_ITEM,autoDelete = "false"),
                  exchange = @Exchange(value = MQConst.EXCHANGE_TOPIC_SMS),
                  key = {MQConst.ROUTING_TOPIC_SMS}
          )
  )
    public void send(SmsDTO smsDTO){

      Map<String,Object> map = new HashMap<>();
      map.put("code",smsDTO.getMessage());

      msmService.send(smsDTO.getMobile(),"369156",map);


    }


}
